﻿using CardWarWEB;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CardWarWEB
{
    public class iColor
    {
        public static Color Lerp(Color a, Color b, float t)
        {
            t = Clamp01(t);
            float aR = Convert.ToSingle(a.R);
            float aG = Convert.ToSingle(a.G);
            float aB = Convert.ToSingle(a.B);
            float aA = Convert.ToSingle(a.A);
            float bR = Convert.ToSingle(b.R);
            float bG = Convert.ToSingle(b.G);
            float bB = Convert.ToSingle(b.B);

            float bA = Convert.ToSingle(b.A);
            float aa = aA + (bA - aA) * t;
            float bb = aR + (bR - aR) * t;
            float cc = aG + (bG - aG) * t;
            float dd = aB + (bB - aB) * t;
            int aaa = Convert.ToInt32(aa);
            int bbb = Convert.ToInt32(bb);
            int ccc = Convert.ToInt32(cc);
            int ddd = Convert.ToInt32(dd);
            Color c = Color.FromArgb(aaa, bbb, ccc, ddd);
            return c;
        }

        public static float Clamp01(float value)
        {
            if (value < 0f)
            {
                return 0f;
            }
            if (value > 1f)
            {
                return 1f;
            }
            return value;
        }


    }
}
